//
//  LXHomeTableViewCell.m
//  bgms_d
//
//  Created by Mountain on 24/2/2019.
//  Copyright © 2019 lachesis-zhu. All rights reserved.
//

#import "LXHomeTableViewCell.h"

@implementation LXHomeTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [self initSycleView];
    // Initialization code
}

- (void)initSycleView {
    self.timeCircle = [[ZZCircleProgress alloc] initWithFrame:CGRectMake(0, 0, self.timeView.lx_width, self.timeView.lx_height) pathBackColor:nil pathFillColor:kAppThemeColor startAngle:-90 strokeWidth:4];
    self.timeCircle.showPoint = NO;
    self.timeCircle.animationModel = CircleIncreaseSameTime;
    self.timeCircle.progress = self.timeProgress;
    self.timeCircle.centerImage = [UIImage imageNamed:@"tempStart"];
    [self.timeView addSubview:self.timeCircle];
    UITapGestureRecognizer *timeTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(timeDown:)];
    timeTap.numberOfTapsRequired = 1;
    timeTap.numberOfTouchesRequired = 1;
    [self.timeView addGestureRecognizer:timeTap];
    
    self.tempCircle = [[ZZCircleProgress alloc] initWithFrame:CGRectMake(0, 0, self.tempView.lx_width, self.tempView.lx_height) pathBackColor:nil pathFillColor:kAppThemeColor startAngle:-90 strokeWidth:4];
    self.tempCircle.showPoint = NO;
    self.tempCircle.animationModel = CircleIncreaseSameTime;
    self.tempCircle.progress = self.tempProgress;
    self.tempCircle.centerImage = [UIImage imageNamed:@"timeStart"];
    [self.tempView addSubview:self.tempCircle];
    UITapGestureRecognizer *tempTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(foodDown:)];
    tempTap.numberOfTapsRequired = 1;
    tempTap.numberOfTouchesRequired = 1;
    [self.tempView addGestureRecognizer:tempTap];
}

- (void)foodDown:(UIGestureRecognizer *)sender {
    sender.view.tag = 0;
    if (self.delegate && [self.delegate respondsToSelector:@selector(homeTableViewCell:btnDown:)]) {
        [self.delegate homeTableViewCell:self btnDown:sender.view];
    }
}

- (void)timeDown:(UIGestureRecognizer *)sender {
    sender.view.tag = 1;
    if (self.delegate && [self.delegate respondsToSelector:@selector(homeTableViewCell:btnDown:)]) {
        [self.delegate homeTableViewCell:self btnDown:sender.view];
    }
}

- (void)setTimeProgress:(CGFloat)timeProgress
{
    if (self.timeDisable) {
        return;
    }
    _timeProgress = timeProgress;
    self.timeCircle.progress = timeProgress;
    if (timeProgress >= 0.98) {
        self.timeCircle.centerImage = [UIImage imageNamed:@"tempEnd"];
    } else {
        self.timeCircle.centerImage = [UIImage imageNamed:@"tempStart"];
    }
}

- (void)setTempProgress:(CGFloat)tempProgress
{
    _tempProgress = tempProgress;
    self.tempCircle.progress = tempProgress;
    if (tempProgress >= 0.98) {
        self.tempCircle.centerImage = [UIImage imageNamed:@"timeEnd"];
    } else {
        self.tempCircle.centerImage = [UIImage imageNamed:@"timeStart"];
    }
}

- (void)clearHistory {
    self.tempProgress = 0;
    self.timeProgress = 0;
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
